﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using TestStarter.Model;
using TestStarter.Util;

namespace TestStarter.Wpf.WpfPage
{
    /// <summary>
    /// Interaction logic for TestsReportsPage.xaml
    /// </summary>
    public partial class TestsReportsPage : Page
    {
        List<ReportOverviewModel> OverviewList = new List<ReportOverviewModel>();
        public ObservableCollection<TestGroup> GroupDetailsList { get; set; }

        public TestsReportsPage()
        { 
            ReportOverviewModel ROM1 = new ReportOverviewModel();
            ReportOverviewModel ROM2 = new ReportOverviewModel();
            ReportOverviewModel ROM3 = new ReportOverviewModel();

            ROM1.TestGroupList = TSuitsGroupData;
            ROM2.TestGroupList = TSuitsGroupData2;
            ROM3.TestGroupList = TSuitsGroupData3;

            OverviewList.Add(ROM1);
            OverviewList.Add(ROM2);
            OverviewList.Add(ROM3);

            GroupDetailsList = TSuitsGroupDataDetailsLogin;


            InitializeComponent();

            OverviewListView.ItemsSource = OverviewList;
            OverviewListView.Items.Refresh();

            DetailsListView.ItemsSource = GroupDetailsList;
            DetailsListView.Items.Refresh(); 

            TestReportSuites.ItemsSource = TSuitsGroupData;
            TestReportSuites.Items.Refresh();
        }

        #region Overview Page Data
        public ObservableCollection<TestGroup> TSuitsGroupData = new ObservableCollection<TestGroup>()
        {
            new TestGroup() { GroupName = "Login", PassedItems=3, FailedItems=0, SkipedItems=0, GroupTestStartDate = new DateTime(2014,09,22,12,24,00), GroupTestEndDate = new DateTime(2014,09,22,12,24,17)},
            new TestGroup() { GroupName = "Home Page",  PassedItems=7, FailedItems=0, SkipedItems=0, GroupTestStartDate = new DateTime(2014,09,22,12,24,17), GroupTestEndDate = new DateTime(2014,09,22,12,24,37)},
            new TestGroup() { GroupName = "Contact Us", PassedItems=2, FailedItems=0, SkipedItems=0, GroupTestStartDate = new DateTime(2014,09,22,12,24,37), GroupTestEndDate = new DateTime(2014,09,22,12,24,39)},
        };

        public ObservableCollection<TestGroup> TSuitsGroupData2 = new ObservableCollection<TestGroup>()
        {
            new TestGroup() { GroupName = "Login", PassedItems=2, FailedItems=1, SkipedItems=0, GroupTestStartDate = new DateTime(2014,08,19,12,24,00), GroupTestEndDate = new DateTime(2014,08,19,12,24,16)},
            new TestGroup() { GroupName = "Home Page",  PassedItems=4, FailedItems=2, SkipedItems=1, GroupTestStartDate = new DateTime(2014,08,19,12,24,16), GroupTestEndDate = new DateTime(2014,08,19,12,24,33)},
            new TestGroup() { GroupName = "Contact Us", PassedItems=1, FailedItems=1, SkipedItems=0, GroupTestStartDate = new DateTime(2014,08,19,12,24,33), GroupTestEndDate = new DateTime(2014,08,19,12,24,49)},
        };

        public ObservableCollection<TestGroup> TSuitsGroupData3 = new ObservableCollection<TestGroup>()
        {
            new TestGroup() { GroupName = "Login", PassedItems=1, FailedItems=1, SkipedItems=1, GroupTestStartDate = new DateTime(2014,07,10,12,24,00), GroupTestEndDate = new DateTime(2014,07,10,12,24,32)},
            new TestGroup() { GroupName = "Home Page",  PassedItems=2, FailedItems=4, SkipedItems=1, GroupTestStartDate = new DateTime(2014,07,10,12,24,32), GroupTestEndDate = new DateTime(2014,07,10,12,24,47)},
            new TestGroup() { GroupName = "Contact Us", PassedItems=0, FailedItems=1, SkipedItems=1, GroupTestStartDate = new DateTime(2014,07,10,12,24,47), GroupTestEndDate = new DateTime(2014,07,10,12,24,54)},
        };
        #endregion

        #region Login Group Details
        public ObservableCollection<TestGroup> TSuitsGroupDataDetailsLogin = new ObservableCollection<TestGroup>()
        {
            new TestGroup() { GroupName = "Login", GroupItemList = TSuitsGroupDetailsLogin1},
            new TestGroup() { GroupName = "Login", GroupItemList = TSuitsGroupDetailsLogin2},
            new TestGroup() { GroupName = "Login", GroupItemList = TSuitsGroupDetailsLogin3}
        };

        public static ObservableCollection<TestGroupItem> TSuitsGroupDetailsLogin1 = new ObservableCollection<TestGroupItem>()
        {
            new TestGroupItem() { ItemName = "InvalidCredentials", Status = ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,09,22,12,24,00), ItemTestEndDate = new DateTime(2014,09,22,12,24,07)},
            new TestGroupItem() { ItemName = "ValidCredentials", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,09,22,12,24,07), ItemTestEndDate = new DateTime(2014,09,22,12,24,11)},
            new TestGroupItem() { ItemName = "Remember", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,09,22,12,24,11), ItemTestEndDate = new DateTime(2014,09,22,12,24,17)},
        };

        public static ObservableCollection<TestGroupItem> TSuitsGroupDetailsLogin2 = new ObservableCollection<TestGroupItem>()
        {
            new TestGroupItem() { ItemName = "InvalidCredentials", Status =ItemStatus.PASSED,ItemTestStartDate = new DateTime(2014,08,19,12,24,00), ItemTestEndDate = new DateTime(2014,08,19,12,24,09)},
            new TestGroupItem() { ItemName = "ValidCredentials", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,08,19,12,24,09), ItemTestEndDate = new DateTime(2014,08,19,12,24,15)},
            new TestGroupItem() { ItemName = "Remember", Status =ItemStatus.FAILED, ItemTestStartDate = new DateTime(2014,08,19,12,24,15), ItemTestEndDate = new DateTime(2014,08,19,12,24,16)},
        };

        public static ObservableCollection<TestGroupItem> TSuitsGroupDetailsLogin3 = new ObservableCollection<TestGroupItem>()
        {
            new TestGroupItem() { ItemName = "InvalidCredentials", Status =ItemStatus.FAILED, ItemTestStartDate = new DateTime(2014,07,10,12,24,00), ItemTestEndDate = new DateTime(2014,07,10,12,24,18)},
            new TestGroupItem() { ItemName = "ValidCredentials", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,07,10,12,24,18), ItemTestEndDate = new DateTime(2014,07,10,12,24,25)},
            new TestGroupItem() { ItemName = "Remember", Status =ItemStatus.SKIPPED, ItemTestStartDate = new DateTime(2014,07,10,12,24,25), ItemTestEndDate = new DateTime(2014,07,10,12,24,32)},
        };
        #endregion

        #region HomePage Group Details

        public ObservableCollection<TestGroup> TSuitsGroupDataDetailsHomePage = new ObservableCollection<TestGroup>()
        {
            new TestGroup() { GroupName = "Home Page", GroupItemList = TSuitsGroupDetailsHome1},
            new TestGroup() { GroupName = "Home Page", GroupItemList = TSuitsGroupDetailsHome2},
            new TestGroup() { GroupName = "Home Page", GroupItemList = TSuitsGroupDetailsHome3}
        };

        public static ObservableCollection<TestGroupItem> TSuitsGroupDetailsHome1 = new ObservableCollection<TestGroupItem>()
        {
            new TestGroupItem() { ItemName = "HomePageContent", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,09,22,12,24,17), ItemTestEndDate = new DateTime(2014,09,22,12,24,24)},
            new TestGroupItem() { ItemName = "HomePageSubMenu1", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,09,22,12,24,24), ItemTestEndDate = new DateTime(2014,09,22,12,24,26)},
            new TestGroupItem() { ItemName = "HomePageSubMenu2", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,09,22,12,24,26), ItemTestEndDate = new DateTime(2014,09,22,12,24,29)},
            new TestGroupItem() { ItemName = "HomePageSubMenu3", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,09,22,12,24,29), ItemTestEndDate = new DateTime(2014,09,22,12,24,34)},
            new TestGroupItem() { ItemName = "HomePageSubMenu4", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,09,22,12,24,34), ItemTestEndDate = new DateTime(2014,09,22,12,24,35)},
            new TestGroupItem() { ItemName = "HomePageSubMenu5", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,09,22,12,24,35), ItemTestEndDate = new DateTime(2014,09,22,12,24,36)},
            new TestGroupItem() { ItemName = "HomePageSubMenu6", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,09,22,12,24,36), ItemTestEndDate = new DateTime(2014,09,22,12,24,37)},
        };

        public static ObservableCollection<TestGroupItem> TSuitsGroupDetailsHome2 = new ObservableCollection<TestGroupItem>()
        {
            new TestGroupItem() { ItemName = "HomePageContent", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,08,19,12,24,16), ItemTestEndDate = new DateTime(2014,08,19,12,24,21)},
            new TestGroupItem() { ItemName = "HomePageSubMenu1", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,08,19,12,24,21), ItemTestEndDate = new DateTime(2014,08,19,12,24,25)},
            new TestGroupItem() { ItemName = "HomePageSubMenu2", Status =ItemStatus.FAILED,ItemTestStartDate = new DateTime(2014,08,19,12,24,25), ItemTestEndDate = new DateTime(2014,08,19,12,24,26)},
            new TestGroupItem() { ItemName = "HomePageSubMenu3", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,08,19,12,24,26), ItemTestEndDate = new DateTime(2014,08,19,12,24,28)},
            new TestGroupItem() { ItemName = "HomePageSubMenu4", Status =ItemStatus.FAILED, ItemTestStartDate = new DateTime(2014,08,19,12,24,28), ItemTestEndDate = new DateTime(2014,08,19,12,24,29)},
            new TestGroupItem() { ItemName = "HomePageSubMenu5", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,08,19,12,24,29), ItemTestEndDate = new DateTime(2014,08,19,12,24,31)},
            new TestGroupItem() { ItemName = "HomePageSubMenu6", Status =ItemStatus.SKIPPED, ItemTestStartDate = new DateTime(2014,08,19,12,24,31), ItemTestEndDate = new DateTime(2014,08,19,12,24,33)},
        };

        public static ObservableCollection<TestGroupItem> TSuitsGroupDetailsHome3 = new ObservableCollection<TestGroupItem>()
        {
            new TestGroupItem() { ItemName = "HomePageContent", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,07,10,12,24,32), ItemTestEndDate = new DateTime(2014,07,10,12,24,37)},
            new TestGroupItem() { ItemName = "HomePageSubMenu1", Status =ItemStatus.FAILED, ItemTestStartDate = new DateTime(2014,07,10,12,24,37), ItemTestEndDate = new DateTime(2014,07,10,12,24,38)},
            new TestGroupItem() { ItemName = "HomePageSubMenu2", Status =ItemStatus.FAILED, ItemTestStartDate = new DateTime(2014,07,10,12,24,38), ItemTestEndDate = new DateTime(2014,07,10,12,24,39)},
            new TestGroupItem() { ItemName = "HomePageSubMenu3", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,07,10,12,24,39), ItemTestEndDate = new DateTime(2014,07,10,12,24,43)},
            new TestGroupItem() { ItemName = "HomePageSubMenu4", Status =ItemStatus.FAILED, ItemTestStartDate = new DateTime(2014,07,10,12,24,43), ItemTestEndDate = new DateTime(2014,07,10,12,24,44)},
            new TestGroupItem() { ItemName = "HomePageSubMenu5", Status =ItemStatus.FAILED, ItemTestStartDate = new DateTime(2014,07,10,12,24,44), ItemTestEndDate = new DateTime(2014,07,10,12,24,46)},
            new TestGroupItem() { ItemName = "HomePageSubMenu6", Status =ItemStatus.SKIPPED, ItemTestStartDate = new DateTime(2014,07,10,12,24,46), ItemTestEndDate = new DateTime(2014,07,10,12,24,47)},
        };
        #endregion

        #region ContactUs Group Details

        public ObservableCollection<TestGroup> TSuitsGroupDataDetailsContact = new ObservableCollection<TestGroup>()
        {
            new TestGroup() { GroupName = "Contact Us", GroupItemList = TSuitsGroupDetailsContact1},
            new TestGroup() { GroupName = "Contact Us", GroupItemList = TSuitsGroupDetailsContact2},
            new TestGroup() { GroupName = "Contact Us", GroupItemList = TSuitsGroupDetailsContact3}
        };

        public static ObservableCollection<TestGroupItem> TSuitsGroupDetailsContact1 = new ObservableCollection<TestGroupItem>()
        {
            new TestGroupItem() { ItemName = "ContactUsPageContent", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,09,22,12,24,37), ItemTestEndDate = new DateTime(2014,09,22,12,24,38)},
            new TestGroupItem() { ItemName = "InquiryForm", Status =ItemStatus.PASSED, ItemTestStartDate = new DateTime(2014,09,22,12,24,38), ItemTestEndDate = new DateTime(2014,09,22,12,24,39)},
        };

        public static ObservableCollection<TestGroupItem> TSuitsGroupDetailsContact2 = new ObservableCollection<TestGroupItem>()
        {
            new TestGroupItem() { ItemName = "ContactUsPageContent", Status =ItemStatus.PASSED,  ItemTestStartDate = new DateTime(2014,08,19,12,24,33), ItemTestEndDate = new DateTime(2014,08,19,12,24,39)},
            new TestGroupItem() { ItemName = "InquiryForm", Status =ItemStatus.FAILED, ItemTestStartDate = new DateTime(2014,08,19,12,24,39), ItemTestEndDate = new DateTime(2014,08,19,12,24,49)},
        };

        public static ObservableCollection<TestGroupItem> TSuitsGroupDetailsContact3 = new ObservableCollection<TestGroupItem>()
        {
            new TestGroupItem() { ItemName = "ContactUsPageContent", Status =ItemStatus.FAILED, ItemTestStartDate = new DateTime(2014,07,10,12,24,47), ItemTestEndDate = new DateTime(2014,07,10,12,24,52)},
            new TestGroupItem() { ItemName = "InquiryForm", Status =ItemStatus.SKIPPED, ItemTestStartDate = new DateTime(2014,07,10,12,24,52), ItemTestEndDate = new DateTime(2014,07,10,12,24,54)},
        };

        #endregion

        private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.Source is TabControl)
            {
                if (OverViewTab.IsSelected)
                {
                }
                if (DetailedTab.IsSelected)
                {
                }
            }
        }

        private void TestReportSuites_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            TestGroup selectedItem = TestReportSuites.SelectedItem as TestGroup;

            if(selectedItem.GroupName.Equals("Login"))
            {
                GroupDetailsList = TSuitsGroupDataDetailsLogin;
                DetailsListView.ItemsSource = GroupDetailsList;
                DetailsListView.Items.Refresh(); 
            }
            else if (selectedItem.GroupName.Equals("Home Page"))
            {
                GroupDetailsList = TSuitsGroupDataDetailsHomePage;
                DetailsListView.ItemsSource = GroupDetailsList;
                DetailsListView.Items.Refresh(); 
            }
            else if (selectedItem.GroupName.Equals("Contact Us"))
            {
                GroupDetailsList = TSuitsGroupDataDetailsContact;
                DetailsListView.ItemsSource = GroupDetailsList;
                DetailsListView.Items.Refresh(); 
            }
        }
    }
}

